{% extends 'base.html' %}
{% load staticfiles %}

{% block title %}讲师详情 - 谷粒教育网{% endblock %}

{% block content %}
    <section>
        <div class="wp">
            <ul  class="crumbs">
                <li><a href="/">首页</a>></li>
                <li><a href="{% url 'orgs:teacher_list' %}">授课讲师</a>></li>
                <li>讲师详情</li>
            </ul>
        </div>
    </section>

    <section>
        <div class="wp butler-detail-box butler-diaryd-box clearfix">
            <div class="fl list">
                <div class="butler_detail_list clearfix">
                    <div class="brief">
                        <dl class="des">
                            <dt>
                                <div class="picpic">
                                    <img width="100" height="100" src="{{ MEDIA_URL }}{{ teacher.image }}"/>
                                </div>
                                <div class="btn">
                                <span class="fl btn1 collectionbtn" id="jsLeftBtn">
                                     {% if loveteacher %} 取消收藏 {% else %} 收藏 {% endif %}
                                </span>
                                    <span class="fr btn2 shareBtn bdsharebuttonbox">
                                    <span class="fl">分享</span>
                                    <a href="#" class="bds_more" data-cmd="more"></a>
                                </span>
                                </div>
                            </dt>
                            <dd>
                                <a href="{% url 'orgs:teacher_detail' teacher.id %}">
                                    <h1>{{ teacher.name }}<span class="key picbig">金牌讲师</span></h1>
                                </a>
                                <ul class="cont">
                                    <li>工作年限：<span>{{ teacher.work_year }}年</span></li>
                                    <li>就职公司：<span>{{ teacher.work_company.name }}</span></li>
                                    <li>工作职位：<span>{{ teacher.work_position }}&nbsp;</span></li>
                                    <li>教学特点：<span>{{ teacher.work_style }}</span></li>
                                </ul>
                            </dd>
                        </dl>
                    </div>
                </div>

                <div class="butler_detail_cont clearfix">
                    <div class="left layout">
                        <div class="head">
                            <ul class="tab_header">
                                <li class="active"><a href="{% url 'courses:course_list' %}">全部课程</a> </li>
{#                                <li class="active"><a href="{% url 'orgs:teacher_detail' teacher.id %}">全部课程</a> </li>#}
                            </ul>
                        </div>

                        <div class="companycenter">
                            <div class="group_list brief">
{#                            {% for course in  teacher.courseinfo_set.all %}#}
{#                                <div class="module1_5 box">#}
{#                                    <a href="{% url 'courses:course_detail' course.id %}">#}
{#                                        <img width="214" height="190" class="scrollLoading" src="{{MEDIA_URL }}{{ course.image }}"/>#}
{#                                    </a>#}
{#                                    <div class="des">#}
{#                                        <a href="{% url 'courses:course_detail' course.id %}"><h2>{{ course.name }}</h2></a>#}
{#                                        <span class="fl">时长：<i class="key">{{ course.study_time }}</i></span>#}
{#                                        <span class="fr">学习人数：{{ course.study_num }}</span>#}
{#                                    </div>#}
{#                                    <div class="bottom">#}
{#                                        <span class="fl">{{ course.orginfo.name }}</span>#}
{#                                        <span class="star fr  notlogin" data-favid="15">0</span>#}
{#                                    </div>#}
{#                                </div>#}
{#                            {% endfor %}#}

                            {# 分页显示 #}
                            {% for course in pages %}
                                <div class="module1_5 box">
                                    <a href="{% url 'courses:course_detail' course.id %}">
                                        <img width="214" height="190" class="scrollLoading" src="{{MEDIA_URL }}{{ course.image }}"/>
                                    </a>
                                    <div class="des">
                                        <a href="{% url 'courses:course_detail' course.id %}"><h2>{{ course.name }}</h2></a>
                                        <span class="fl">时长：<i class="key">{{ course.study_time }}</i></span>
                                        <span class="fr">学习人数：{{ course.study_num }}</span>
                                    </div>
                                    <div class="bottom">
                                        <span class="fl">{{ course.orginfo.name }}</span>
                                        <span class="star fr  notlogin" data-favid="15">0</span>
                                    </div>
                                </div>
                            {% endfor %}
                            </div>
                        </div>

                        {# 分页 #}
                        <div class="pageturn">
                            <ul class="pagelist">
                                {# 是否有上一页,有就获取上一页的页码值 #}
                                {% if pages.has_previous %}
                                    <li class="long"><a href="?page_num={{ pages.previous_page_number }}">上一页</a></li>
                                {% endif %}

                                {# 所有页码值 #}
                                {% for num in pages.paginator.page_range %}
                                    <li {% if num == pages.number %} class="active" {% endif %}><a href="?page_num={{ num }}" class="page">{{ num }}</a></li>
                                {% endfor %}

                                {# 是否有下一页,有就获取下一页的页码值 #}
                                {% if pages.has_next %}
                                    <li class="long"><a href="?page_num={{ pages.next_page_number }}">下一页</a></li>
                                {% endif %}

                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <div class="fr list">
                <div class="butler_detail_list">
                    <div class="right butler-company-box">
                        <div class="head">
                            <h1>{{ teacher.work_company.name }}</h1>
                            <p>{{ teacher.work_company.desc }}</p>
                        </div>
                        <div class="pic">
                            <a href="{% url 'orgs:org_detail' teacher.work_company.id %}">
                                <img width="150" height="80" src="{{ MEDIA_URL }}{{ teacher.work_company.image }}"/>
                            </a>
                        </div>
                        <a href="{% url 'orgs:org_detail' teacher.work_company.id %}">
                            <h2 class="center">{{ teacher.work_company.name }}</h2>
                        </a>
                        <p class="center tell">地址：{{ teacher.work_company.address }}</p>
                        <a class="btn" id="jsRightBtn">
                            {% if loveorg %} 取消收藏 {% else %} 收藏 {% endif %}
                        </a>
                    </div>
                </div>
                <div class="butler_detail_cont">
                    <div class="butler_list_box">
                        <div class="right layout">
                            <div class="head">讲师排行榜</div>
                            {% for teacher in sort_teachers %}
                            <dl class="des">
                                <span class="num fl">{{ forloop.counter }}</span>
                                <a href="{% url 'orgs:teacher_detail' teacher.id %}">
                                    <dt>
                                        <img width="50" height="50" class="scrollLoading" src="{{ MEDIA_URL }}{{ teacher.image }}"/>
                                    </dt>
                                </a>
                                <dd>
                                    <a href="{% url 'orgs:teacher_detail' teacher.id %}">
                                        <h1 title="{{ teacher.name }}">{{ teacher.name }}</h1>
                                    </a>
                                    <p>工作年限：<span>{{ teacher.work_year }}年</span></p>
                                </dd>
                            </dl>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}

{% block myjs %}
{# 讲师详情页 收藏功能 #}
    <script>
        // 页面加载
        $(function () {
            // 课程详情页左边的课程收藏
            $('#jsLeftBtn').click(function () {
                var loveid = {{ teacher.id }};
                var lovetype = 3;  // 3 表示讲师收藏
                $.ajax({
                    url: '{% url 'operations:user_love'%}',
                    type: 'GET',
                    data:{
                        loveid: loveid,
                        lovetype: lovetype,
                    },
                    success:function (callback) {
                        if (callback.status == 'ok'){
                            $('#jsLeftBtn').text(callback.msg)
                        }else{
                            alert(callback.msg)
                        }
                    }

                });
            });
            // 课程详情页右边的机构收藏
            $('#jsRightBtn').click(function () {
                var loveid = {{ teacher.work_company.id }};
                var lovetype = 1;  // 1 表示机构收藏
                $.ajax({
                    url: '{% url 'operations:user_love'%}',
                    type: 'GET',
                    data:{
                        loveid: loveid,
                        lovetype: lovetype,
                    },
                    success:function (callback) {
                        if (callback.status == 'ok'){
                            $('#jsRightBtn').text(callback.msg)
                        }else{
                            alert(callback.msg)
                        }
                    }
                });
            });
        });

    </script>
    
{% endblock %}